package org.amicofragile.simpledsl

class Optimizer2 extends Optimizer {
    Closure criteria
    protected groups = [other: {it}]

    def other(Closure c){
		addGroup 'other', c
		this
	}

    def methodMissing(String methodName, args) {
        if(args.size() == 1 && args[0] instanceof Closure){
            addGroup methodName, args[0]
            this
        } else {
            throw new MissingMethodException(methodName)
        }
    }

    private addGroup(String name, Closure c){
        groups[name] = c
    }

    static withCriteria(Closure c){
        new Optimizer2(criteria: c)
    }
}

